﻿Imports System.Data
Imports System.Data.SqlClient
Imports Sistema_InformacionNaviera.BE
Imports Sistema_InformacionNavier.UTIL


Public Class PuertosDALC

    Public Function ListaPuerto(ByVal objPuertosBE As PuertosBE) As List(Of PuertosBE)

        Dim sqlListar As String
        Dim objListaPuertos As New List(Of PuertosBE)
        Dim objPtoBE As PuertosBE = Nothing
        Dim arrSqlParameter(0) As SqlParameter
        Dim ds As DataSet
        Dim dt As DataTable

        Dim objDatos As New AccesoDatos()
        Dim blnExito As Boolean
        Dim strMensaje As String = String.Empty
        Dim intI As Integer = 0

        Try

            sqlListar = "up_ConsultarPuerto"

            arrSqlParameter(0) = New SqlParameter("@DesPto", System.Data.SqlDbType.VarChar)
            arrSqlParameter(0).Value = objPuertosBE.Descripcion
            objListaPuertos = New List(Of PuertosBE)()


            ds = objDatos.DevuelveDataSet(sqlListar, blnExito, strMensaje, arrSqlParameter)
            dt = ds.Tables(0)

            If dt.Rows.Count > 0 Then

                While intI < dt.Rows.Count
                    objPtoBE = New PuertosBE()
                    objPtoBE.Codigo = dt.Rows(intI).ItemArray(0).ToString
                    objPtoBE.Descripcion = dt.Rows(intI).ItemArray(1).ToString
                    intI = intI + 1

                    objListaPuertos.Add(objPtoBE)
                End While
            End If
        Catch ex As Exception
            MsgBox(ex.Message, vbCritical, "Error del sistema")
            Return Nothing
            Exit Function
        End Try

        Return objListaPuertos
    End Function


End Class
